<?php

require('lib/Smarty-3.1.15/libs/Smarty.class.php');
$smarty = new Smarty();

$smarty->template_dir = dirname(__FILE__).'/lib/templates/';
$smarty->compile_dir  = dirname(__FILE__).'/lib/templates_c/';
$smarty->config_dir   = dirname(__FILE__).'/lib/configs/';
$smarty->cache_dir    = dirname(__FILE__).'/cache/';

$smarty->default_modifiers=array('escape:"htmlall"');

if(!$_GET['debug']){
	header('Content-Type: text/event-stream');
	header('Cache-Control: no-cache');
}
define('MAX_EXECUTION_TIME', 60);
ini_set('max_execution_time', MAX_EXECUTION_TIME);

function generateScreen($template, $common, $variables){
	global $smarty;
	
	# common variables
	foreach($common as $varname=>$varvalue){
		$smarty->assign($varname, $varvalue);
	}

	# specific variables
	foreach($variables as $varname=>$varvalue){
		$smarty->assign($varname, $varvalue);
	}

	# assign template to use
	$smarty->assign('template', $template);
	
	# process common template
	return $smarty->fetch('common.tpl');	
}

?>